package com.chinadci.smartcommunitysystembackstage.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.chinadci.smartcommunitysystembackstage.entity.ScsLaw;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsAdmintypeMapper;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsLawMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@Service
public class ScsLawService{
    @Autowired
    private ScsLawMapper mapper;

    private Logger log= LoggerFactory.getLogger(this.getClass());

    //显示全部法律
    public List<ScsLaw> Find(){
        log.info("=====显示法律宣传");
        return mapper.selectList(null);
    }

    //根据发布人查找法律
    public List<ScsLaw> Find(String name){
        log.info("=====根据发布人查找法律");
        QueryWrapper<ScsLaw> qw=new QueryWrapper<>();
        qw.like("l_author",name);
        return mapper.selectList(qw);
    }

    //删除指定删除法律
    public int Del(int id){
        log.info("=====删除指定删除法律");
        QueryWrapper<ScsLaw> qw=new QueryWrapper<>();
        qw.eq("l_id",id);
        return mapper.delete(qw);
    }

    //显示指定法律
    public List<ScsLaw> Finds(int id){
        log.info("=====根据发布人查找法律");
        QueryWrapper<ScsLaw> qw=new QueryWrapper<>();
        qw.eq("l_id",id);
        return mapper.selectList(qw);
    }
}
